import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/5 23:16
 */

public class Solution {
    public boolean predictTheWinner(int[] nums) {
        int n = nums.length;
        // dp[i][j]表示当数组只剩下第i到第j个元素时，当前玩家可以比对手多得的分数
        int[][] dp = new int[n][n];

        // 初始化
        for (int i = 0; i < n; i++) {
            dp[i][i] = nums[i];
        }

        // 填充dp表，从长度为2的子数组开始，逐步增加子数组长度
        for (int len = 2; len <= n; len++) {
            for (int i = 0; i <= n - len; i++) {
                int j = i + len - 1;
                // 状态转移方程
                dp[i][j] = Math.max(nums[i] - dp[i + 1][j], nums[j] - dp[i][j - 1]);
            }
        }
        // 如果dp[0][n-1]大于等于0，则当前玩家可以获胜
        return dp[0][n - 1] >= 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.predictTheWinner(nums));
        }
    }
}